//
//  UserController.m
//  SmallElephant
//
//  Created by Faith on 2022/12/24.
//

#import "UserController.h"
#import "UserPart/UserPartHeaderView.h"
#import "UserPart/UserPartOrderView.h"
#import "UserPart/UserPartButtonView.h"
#import "UserPart/UserPartAppButtonView.h"

@interface UserController ()

/// 顶部占位视图
@property (nonatomic, strong) UIView *placeHolderView;

/// 头部视图
@property (nonatomic, strong) UserPartHeaderView *headerView;

/// 订单视图
@property (nonatomic, strong) UserPartOrderView *orderView;

/// 按钮视图
@property (nonatomic, strong) UserPartButtonView *buttonView;

/// 我的应用视图
@property (nonatomic, strong)  UserPartAppButtonView *appButtonView;


@end

@implementation UserController

- (void)viewDidLoad {
    [self.view addSubview:self.placeHolderView style:@"position: absolute; width: 100%; height: 204px; background: url(bg-my-home@3x);"];
    [super viewDidLoad];
    self.navigationBar.alpha = 0;
    [self.navigationBar applyStyle:@"height: --safe-area-top; "];
    [self.scrollViewContent addSubview:self.headerView style:@"display: flex; margin-top: 10px; flex-direction: row;"];
    [self.scrollViewContent addSubview:self.orderView style:@""];
    [self.scrollViewContent addSubview:self.buttonView style:@""];
    [self.scrollViewContent addSubview:self.appButtonView style:@""];
    [self loadData];
    
    self.scrollView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [self.scrollView.mj_header endRefreshing];
        [self loadData];
    }];
}

/// 懒加载顶部占位视图
- (UIView *)placeHolderView {
    if(!_placeHolderView) {
        _placeHolderView = [[UIView alloc] init];
    }
    return _placeHolderView;
}

- (UserPartHeaderView *)headerView {
    if(!_headerView) {
        _headerView = [[UserPartHeaderView alloc] init];
    }
    return _headerView;
}

- (UserPartOrderView *)orderView {
    if(!_orderView) {
        _orderView = [[UserPartOrderView alloc] init];
    }
    return _orderView;
}

- (UserPartButtonView *)buttonView {
    if(!_buttonView) {
        _buttonView = [[UserPartButtonView alloc] init];
    }
    return _buttonView;
}

- (UserPartAppButtonView *)appButtonView {
    if(!_appButtonView) {
        _appButtonView = [[UserPartAppButtonView alloc] init];
    }
    return _appButtonView;
}

- (void)loadData {
    [self.headerView setData:@{
        @"nickname": @"无名指的等待",
        @"avatar": @"icon-avatar@3x",
        @"id": @"ID:877664664",
    }];
    [self.orderView setData:nil];
    [self.appButtonView setData:nil];
    [self.buttonView setData:nil];
}

@end
